package com.ruoyi.report_lqn.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report_lqn.domain.vo.ReportLqnRhlqclwjlbBaDetailVo;
import com.ruoyi.report_lqn.domain.bo.ReportLqnRhlqclwjlbBaDetailBo;
import com.ruoyi.report_lqn.service.IReportLqnRhlqclwjlbBaDetailService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 乳化沥青蒸发残留物含量试验检测记录-详情
 *
 * @author tll
 * @date 2024-09-12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report_lqn/lqnRhlqclwjlbBaDetail")
public class ReportLqnRhlqclwjlbBaDetailController extends BaseController {

    private final IReportLqnRhlqclwjlbBaDetailService iReportLqnRhlqclwjlbBaDetailService;

    /**
     * 查询乳化沥青蒸发残留物含量试验检测记录-详情列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<ReportLqnRhlqclwjlbBaDetailVo> list(ReportLqnRhlqclwjlbBaDetailBo bo, PageQuery pageQuery) {
        return iReportLqnRhlqclwjlbBaDetailService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出乳化沥青蒸发残留物含量试验检测记录-详情列表
     */
    @SaCheckLogin
    @Log(title = "乳化沥青蒸发残留物含量试验检测记录-详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ReportLqnRhlqclwjlbBaDetailBo bo, HttpServletResponse response) {
        List<ReportLqnRhlqclwjlbBaDetailVo> list = iReportLqnRhlqclwjlbBaDetailService.queryList(bo);
        ExcelUtil.exportExcel(list, "乳化沥青蒸发残留物含量试验检测记录-详情", ReportLqnRhlqclwjlbBaDetailVo.class, response);
    }

    /**
     * 获取乳化沥青蒸发残留物含量试验检测记录-详情详细信息
     *
     * @param detailId 主键
     */
    @SaCheckLogin
    @GetMapping("/{detailId}")
    public R<ReportLqnRhlqclwjlbBaDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long detailId) {
        return R.ok(iReportLqnRhlqclwjlbBaDetailService.queryById(detailId));
    }

    /**
     * 新增乳化沥青蒸发残留物含量试验检测记录-详情
     */
    @SaCheckLogin
    @Log(title = "乳化沥青蒸发残留物含量试验检测记录-详情", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ReportLqnRhlqclwjlbBaDetailBo bo) {
        return toAjax(iReportLqnRhlqclwjlbBaDetailService.insertByBo(bo));
    }

    /**
     * 修改乳化沥青蒸发残留物含量试验检测记录-详情
     */
    @SaCheckLogin
    @Log(title = "乳化沥青蒸发残留物含量试验检测记录-详情", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ReportLqnRhlqclwjlbBaDetailBo bo) {
        return toAjax(iReportLqnRhlqclwjlbBaDetailService.updateByBo(bo));
    }

    /**
     * 删除乳化沥青蒸发残留物含量试验检测记录-详情
     *
     * @param detailIds 主键串
     */
    @SaCheckLogin
    @Log(title = "乳化沥青蒸发残留物含量试验检测记录-详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{detailIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] detailIds) {
        return toAjax(iReportLqnRhlqclwjlbBaDetailService.deleteWithValidByIds(Arrays.asList(detailIds), true));
    }
}
